<template>
  <a-modal
    width="480px"
    v-model="innerVisible"
    :title="$t('all.autotext158')"
    :maskClosable="false"
  >
    <a-form-model labelAlign="left">
      <a-form-model-item :label="$t('all.autotext1514')">
        <a-textarea v-model="refuseReason" />
      </a-form-model-item>
    </a-form-model>

    <div slot="footer" class="dialog-footer">
      <a-button type="danger" @click="close">{{ $t('all.autotext1072') }}</a-button>
      <a-button type="primary" @click="submit">{{ $t('all.autotext694') }}</a-button>
    </div>

    <identityCheck v-model="identityCheckShow" @ok="handleOk" />
  </a-modal>
</template>

<script>
import modalMixin from '@/utils/modal.mixin'
import { auditSpecial } from '@/api/cost/audit'
import identityCheck from '../../cost-auditing/components/identityCheck'

export default {
  components: { identityCheck },
  props: ['req'],
  mixins: [modalMixin],
  data () {
    return {
      identityCheckShow: false,
      status: '',
      refuseReason: ''
    }
  },
  methods: {
    async handleOk () {
      await auditSpecial({
        ...this.req,
        status: this.status,
        refuseReason: this.refuseReason
      })
      this.innerVisible = false
      this.refuseReason = ''
      this.$message.success(this.$t('all.autotext470'))
      this.$emit('success')
    },
    submit () {
      this.status = 1
      this.identityCheckShow = true
    },
    close () {
      if (!this.refuseReason) {
        this.$message.warning(this.$t('all.autotext653'))
        return
      }
      this.status = -1
      this.identityCheckShow = true
    }
  }
}
</script>

<style lang="less" scoped>
</style>
